<template>
  <div class="identityTransfer">
    <Icon type="android-checkmark-circle" size="150"/>
    <span v-if="state" style="font-size: larger">验证成功！请开始工商登记业务。</span>
    <div v-if="pathShow" style="font-size: larger;padding-top: 10px;">
      <Row style="font-size: larger">
        <router-link :to="{ name: 'MySetupList',params: {'regorg': regorg} }">
          <span style="font-size: larger">设立企业</span>
        </router-link>
      </Row>
      <Row style="font-size: larger">
        <router-link :to="{ name: 'MyBusiness',params: {'regorg': regorg} }">
          <span style="font-size: larger">我的业务</span>
        </router-link>
      </Row>
      <Row style="font-size: larger">
        <router-link :to="{ name: 'BusinessConfirmList',params: {'regorg': regorg} }">
          <span style="font-size: larger">业务确认</span>
        </router-link>
      </Row>
    </div>
  </div>
</template>

<script>
  import request from '../../utils/request'
  import wechat from '../../assets/js/weixinjs'
    export default {
      data() {
        return {
          state: false,
          pathShow: false,
          regorg: ''
        }
      },
      methods: {
        init() {
          this.regorg = localStorage.getItem('regrog')
          if (this.regorg == null || this.regorg === 'undefined' || this.regorg === '') {
            this.regorg = '110106'
          }
          wechat.wechatLogin(this.doLogin, this.regorg)
        },
        doLogin() {
          let lastToken = localStorage.getItem('nowToken')
          let nowToken = this.$route.query.token
          if (lastToken) {
            localStorage.setItem('lastToken', lastToken)
          }
          localStorage.setItem('nowToken', nowToken)
          let code = wechat.GetQueryString('code')
          let outTradeNo = wechat.GetQueryString('out_trade_no')
          let outExtra = wechat.GetQueryString('out_extra')
          let companyIdentityId = (outTradeNo === 'companyIdentity' ? outExtra : '')
          request.get('/interface/out/wechat/identityRedirect.do', {
            uid: this.$route.query.uid,
            token: this.$route.query.token,
            regorg: this.regorg,
            code: code,
            companyIdentityId: companyIdentityId
          }).then((response) => {
            if (response.data.result === 'success') {
              this.state = true
              let respData = response.data.data
              if (respData.openId) {
                localStorage.setItem('openId_' + this.regorg, respData.openId)
              }
              if (respData.personSign === '1') {
                this.$store.commit('setLoginState', true)
                this.pathShow = true
              }
            } else {
              this.$ErrorAlert(response.data.message)
            }
          })
        }
      },
      mounted() {
        // this.init()
        // this.doLogin()
      }
    }
</script>

<style scoped>
.identityTransfer{
  text-align: center;
  padding-top: 20%;
}
.identityTransfer .ivu-icon{
  display: block;
  margin: 1rem auto;
  color: green;
}
</style>
